﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Web;
using System.Data.OleDb;
using Aandelendelen.Db;

namespace Aandelendelen.Obs
{
	public class UserinfoCollection : Collection<Userinfo>
	{
		/// <summary>
		/// Gets all referrals of the given user
		/// </summary>
		/// <param name="referrer">the user to get referrals of.</param>
		public UserinfoCollection(Userinfo referrer)
			: base()
		{
			Query query = new Query("s_getreferrals", "referrer", referrer.Id, OleDbType.Integer);

			ResultSet resultSet = (ResultSet)query.Execute();

			for (int i = 0; i < resultSet.Count; i++)
			{
				this.Add(new Userinfo(resultSet, i));
			}

		}
	}
}